/*
 * CodeSaveCommand.java
 *
 * Created on 2006년 3월 29일 (수), 오후 4:11
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.qbooks.app.board;

import java.util.*;





import javax.servlet.*;
import javax.servlet.http.*;

import org.json.simple.JSONObject;

import com.zll.framework.model.HashBox;
import com.zll.framework.model.HashList;
import com.zll.framework.servlet.Command;
import com.zll.framework.util.StringUtil;
import com.qbooks.app.AppDAO;
import com.qbooks.common.CommonUtil;





/**
 *
 * @author eastar
 */
public class BoardListCommand implements Command
{
	private final String D = "\"";

    public String execute(HttpServletRequest  request, HttpServletResponse response)
    throws Exception
    {

    	AppDAO dao = new AppDAO();
    	

    	HashBox box = new HashBox(request);
    	
    	String os	= StringUtil.nvl(request.getAttribute("os"));
    	String id	= StringUtil.nvl(request.getParameter("id"));
    	
    	
    	/* 자동 로그인 처리 */
    	HttpSession session = request.getSession();
    	
    	//id가 있으면 회원정보 조회, 없으면 로그아웃
    	if ("".equals(id)) {
    		session.invalidate();
    	} else {
    		HashList list = dao.selectMember(box.getParam());

			if (list.size() == 1) {
	    		session.setAttribute("session.user_id", list.get("member_id",0));
				session.setAttribute("session.user_name", list.get("member_name",0));
				session.setAttribute("session.user_auth", "M");
			} else {
				session.invalidate();
			}
    	}
    	


		if ("android".equals(os)) {
			
		}
		else if ("ios".equals(os)) {
			
		}

		request.setAttribute("boardList", dao.selectBoardList(box.getParam()));


		return "/app/board/boardList.jsp";
    }
}
